/*
Copyright To change this template, choose Tools | Templates
Copyright and open the template in the editor.
 */
package com.click.app.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * @author Joel Chuca Condo
 * @date 16/06/2009
 */
@Entity(name="laundries")
public class Laundry extends BaseObject {

    private Long id;
    private String name;
    private String address;
    private Date dateSing;

    private List<PeriodPaymentLaundry> periodPaymentLaundryList;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name = "id_laundry")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "address")
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }



    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Laundry)) {
            return false;
        }
        Laundry other = (Laundry) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("country", this.id)
                .append("name", this.name)
                .append("address", this.address)
                .toString();
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "laundry")
    public List<PeriodPaymentLaundry> getPeriodPaymentLaundryList() {
        return periodPaymentLaundryList;
    }

    public void setPeriodPaymentLaundryList(List<PeriodPaymentLaundry> periodPaymentLaundryList) {
        this.periodPaymentLaundryList = periodPaymentLaundryList;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "date_sing")
    public Date getDateSing() {
        return dateSing;
    }

    public void setDateSing(Date dateSing) {
        this.dateSing = dateSing;
    }

}
